﻿using System;

namespace Daemon.Data.Substructure.Framework.Extension
{
	public static class TimeSpanExtension
	{
		public static TimeSpan RoundSecond(this TimeSpan time)
		{
			if (time.Seconds == 0)
			{
				return time;
			}
			else if (time.Seconds >= 30)
			{
				return time.Add(new TimeSpan(0, 0, 60 - time.Seconds));
			}
			else
			{
				return time.Subtract(new TimeSpan(0, 0, time.Seconds));
			}
		}
	}
}
